diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-10-12 17:24:13 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-11 18:14:41 +0100 |
| commit | 00f147a7a687d5772bcc538bc606cfff972178cd (patch) | |
| tree | 27eabeb83c05e14162c51b69d4a6f36d461947fc /src/pages/sujet/[slug].tsx | |
| parent | c87c615b5866b8a8f361eeb0764bfdea85740e90 (diff) | |
feat(components): add a Time component
Instead of using helpers functions to format the date each time we need
to use a time element, it makes more sense to create a new component
dedicated to this task.
Diffstat (limited to 'src/pages/sujet/[slug].tsx')
| -rw-r--r-- | src/pages/sujet/[slug].tsx | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/pages/sujet/[slug].tsx b/src/pages/sujet/[slug].tsx index cacc972..87c3340 100644 --- a/src/pages/sujet/[slug].tsx +++ b/src/pages/sujet/[slug].tsx @@ -13,6 +13,7 @@ import { type MetaItemData, PageLayout, PostsList, + Time, } from '../../components'; import { getAllTopicsSlugs, @@ -24,7 +25,6 @@ import styles from '../../styles/pages/topic.module.scss'; import type { NextPageWithLayout, PageLink, Topic } from '../../types'; import { ROUTES } from '../../utils/constants'; import { - getFormattedDate, getLinksListItems, getPageLinkFromRawData, getPostsWithUrl, @@ -60,18 +60,6 @@ const TopicPage: NextPageWithLayout<TopicPageProps> = ({ url: `${ROUTES.TOPICS}/${slug}`, }); - /** - * Retrieve a formatted date (and time). - * - * @param {string} date - A date string. - * @returns {JSX.Element} The formatted date wrapped in a time element. - */ - const getDate = (date: string): JSX.Element => { - const isoDate = new Date(`${date}`).toISOString(); - - return <time dateTime={isoDate}>{getFormattedDate(date)}</time>; - }; - const headerMeta: (MetaItemData | undefined)[] = [ { id: 'publication-date', @@ -80,7 +68,7 @@ const TopicPage: NextPageWithLayout<TopicPageProps> = ({ description: 'TopicPage: publication date label', id: 'KV+NMZ', }), - value: getDate(dates.publication), + value: <Time date={dates.publication} />, }, dates.update ? { @@ -90,7 +78,7 @@ const TopicPage: NextPageWithLayout<TopicPageProps> = ({ description: 'TopicPage: update date label', id: '9DfuHk', }), - value: getDate(dates.update), + value: <Time date={dates.update} />, } : undefined, officialWebsite |
